<% presenters = presenter.collection_presenters %>
<% if presenters.blank? %>
  <% presenter.presenter_types.each do |type| %>
    <%= render 'relationships_parent_row_empty', type: type, presenter: presenter %>
  <% end %>
<% else %>

  <%# Render presenters which aren't specified in the 'presenter_types' %>
  <% presenter.grouped_presenters(except: presenter.presenter_types).each_pair do |model_name, items| %>
    <%= render 'relationships_parent_row', type: model_name, items: items, presenter: presenter %>
  <% end %>

  <%# Render grouped presenters showing rows or an 'empty' row if there are none for that type %>
  <% presenter.presenter_types.each do |type| %>
    <% if presenter.grouped_presenters(filtered_by: type).blank? %>
      <%= render 'relationships_parent_row_empty', type: type, presenter: presenter %>
    <% else %>
      <% presenter.grouped_presenters(filtered_by: type).each_pair do |model_name, items| %>
        <%= render 'relationships_parent_row', type: type, items: items, presenter: presenter %>
      <% end %>
    <% end %>
  <% end %>
<% end %>
